function callback123(json) {
	return json;
}



var tgd = tgd || {};
tgd.Services = tgd.Services || {};
tgd.Services.RESTim = tgd.Services.RESTim || {};

tgd.Services.RESTim.MessageList = function () {
	tgd.Services.RESTim.MessageList.prototype.log = function(txt) {
		var now = new Date();
		var div = document.createElement("div");
		var msgLog = document.getElementById("msgLog");
		div.innerHTML = "<span class='date'>" + now.getHours() + ":" + (now.getMinutes() < 10 ? "0" : "") + now.getMinutes() + ":" + (now.getSeconds() < 10 ? "0" : "") + now.getSeconds() + "</span> " + txt;
		msgLog.insertBefore(div, (msgLog.hasChildNodes() ? msgLog.childNodes[0] : null));
	}

	this.log("tgd.Services.RESTim.MessageList object created");

	this.onRefresh = null;

	if (tgd.Services.RESTim.MessageList._initialized === undefined) {

		tgd.Services.RESTim.MessageList.prototype.refresh = function() {
			this.log("GET all messages");
			var self = this;

			this._request = new XMLHttpRequest();
			this._request.onreadystatechange = function() {
				if (self._request.readyState == 4) {
					self._data = eval(self._request.responseText);
					self.onRefresh();
				}
			}
			this._request.open("GET", "http://timmytooltastix.appspot.com/messages", true);
			this._request.setRequestHeader("If-Modified-Since", "Thu, 17 Jun 1982 00:00:00 GMT");  //IE caching
			//todo:  send headers as needed
			this._request.send(null);
		}

		tgd.Services.RESTim.MessageList._initialized = true;
	}
}
